//
//  PwdChangeViewController.m
//  JiuLe
//
//  Created by xcq on 15/12/6.
//  Copyright © 2015年 Fine. All rights reserved.
//

#import "PwdChangeViewController.h"

@interface PwdChangeViewController ()
@property (weak, nonatomic) IBOutlet UITextField *oldPwd;
@property (weak, nonatomic) IBOutlet UITextField *Pwd;
@property (weak, nonatomic) IBOutlet UITextField *Confirm;

@end

@implementation PwdChangeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"密码设置";
    
    UIColor *color = [UIColor lightGrayColor];
    _oldPwd.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@"旧密码" attributes:@{NSForegroundColorAttributeName: color}];
    _Pwd.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@"新密码" attributes:@{NSForegroundColorAttributeName: color}];
    _Confirm.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@"密码确认" attributes:@{NSForegroundColorAttributeName: color}];
    [self showNavBarWithRightTitle:nil
                    andRightAction:nil
                     andLeftAction:@selector(homeControllerBackTo)
                 andRightBtnIsShow:NO];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (IBAction)confirmEvent:(id)sender {
    if (_oldPwd.text.length == 0) {
        TIPS(@"请输入旧密码");
    } else if (![_oldPwd.text isEqualToString:[[NSUserDefaults standardUserDefaults] objectForKey:UserDataPassWord]]) {
        TIPS(@"旧密码输入错误");
    } else if (_Pwd.text.length == 0) {
        TIPS(@"请输入新密码");
    } else if (_Confirm.text.length == 0){
        TIPS(@"请再次输入您的新密码");
    } else if(![_Confirm.text isEqualToString:_Pwd.text]){
        TIPS(@"两次密码输入不一致，请确认！");
    }
}

- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
//    if (textField.tag) {
//
//    }
    return YES;
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
